<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组案例</title>

    <script>
        var sum = 0;
        var array = [2, 6, 1, 7, 4];
        for (var i = 0; i < array.length; i++) {
            sum += array[i];
        }
        console.log('数组和:' + sum);
        console.log('数组平均数:' + (sum / array.length));
    </script>

</head>

<body>

</body>

</html>